import React, { Component } from 'react';
import axios from 'axios';

export default class App extends Component {
  getStudentsData = () => {
    axios
      .get('http://localhost:3000/api1/students')
      .then((response) => {
        console.log('成功了', response.data);
      })
      .catch((error) => {
        console.log('失败了', error.message);
      });
  };
  getCarsData = () => {
    axios
      .get('http://localhost:3000/api2/cars')
      .then((response) => {
        console.log('成功了', response.data);
      })
      .catch((error) => {
        console.log('失败了', error.message);
      });
  };
  render() {
    return (
      <div>
        <button onClick={this.getStudentsData}>点我发送学生数据</button>
        <button onClick={this.getCarsData}>点我发送汽车数据</button>
      </div>
    );
  }
}
